from pydantic_settings import BaseSettings, SettingsConfigDict

class Settings(BaseSettings):
    #-*- App Config -*-
    APP_NAME: str = "通用工具网站"
    DEBUG: bool = False

    #-- Database Config --#
    POSTGRES_USER: str
    POSTGRES_PASSWORD: str
    POSTGRES_SERVER: str
    POSTGRES_PORT: int = 5432
    POSTGRES_DB: str

    @property
    def database_url(self) -> str:
        """Constructs the full database URL from individual parts."""
        return f"postgresql+asyncpg://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_SERVER}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"

    #-- Pydantic model config --#
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding='utf-8')


# Instantiate the settings object
settings = Settings()
